package com.jh.xiaomicunchu;

import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.jh.storageview.StorageBean;
import com.jh.storageview.StorageHelper;
import com.jh.storageview.StorageView;
import com.jh.storageview.StorageViewGroup;

public class MainActivity extends AppCompatActivity {


    StorageView storage_view;

    Handler                 mHandler = new Handler();
    StorageBean storageBean1 = new StorageBean(5, 5, 10, 10, 10, 10, 10, 10);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

        StorageViewGroup viewById = findViewById(R.id.storage);
        StorageHelper helper = viewById.getHelper();

        viewById.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                helper.setSysGTitle("固件");
                helper.setSysDTitle("数据");
                helper.setDocTitle("文档");
                helper.setPkgTitle("安装包");
                helper.setVideoTitle("视频");
                helper.setSoundTitle("音频");
                helper.setImgTitle("图片");
                helper.setAppTitle("应用");

                helper.setSysGSummary(storageBean1.BeanSysOffset+"%");
                helper.setSysDSummary(storageBean1.BeanSysDOffset+"%");
                helper.setDocSummary(storageBean1.BeanDocOffset+"%");
                helper.setPkgSummary(storageBean1.BeanPkgOffset+"%");
                helper.setVideoSummary(storageBean1.BeanVideoOffset+"%");
                helper.setSoundSummary(storageBean1.BeanSoundOffset+"%");
                helper.setImgSummary(storageBean1.BeanImgOffset+"%");
                helper.setAppSummary(storageBean1.BeanAppOffset+"%");

                helper.updateData(storageBean1);

                viewById.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
}